<template>
	<view class="">
		<view class="nav">
			<u-navbar title-color="#fff" back-icon-color="#ffffff" :is-back="true" :background="background"
				:back-text-style="{color: '#fff'}" title="设置" back-text="返回" />

		</view>
		<view class="cell-wrap">
			<u-cell-group>
				<u-cell-item center index="1" @click="toUserInfo" arrow title="个人信息" :titleStyle="titleStyle" />
				<u-cell-item center index="2" @click="attestation" arrow title="实名认证" :titleStyle="titleStyle" />
				<u-cell-item center index="2" @click="updatePassword" arrow title="修改密码" :titleStyle="titleStyle" />
			</u-cell-group>
		</view>
		<button class="footer" @tap="outLogin">退出登录</button>
	</view>
</template>

<script>
	import App from '../../App.vue'
	import{outLogin} from "../../api/login/user.js"
	export default {
		data() {
			return {
				// 背景
				background: {
					backgroundColor: '#f8f8f8',

					// 导航栏背景图
					//background: 'url(https://cdn.uviewui.com/uview/swiper/1.jpg) no-repeat',
					// 还可以设置背景图size属性
					// backgroundSize: 'cover',

					// 渐变色
					backgroundImage: 'linear-gradient(45deg, rgb(28, 187, 180), rgb(141, 198, 63))'
				},
			}
		},
		methods: {
			// 转到个人资料界面
			toUserInfo() {
				uni.navigateTo({
					url: '../user/index',
					animationType: 'pop-in',
					animationDuration: 200
				})
			},
			attestation() {
				uni.navigateTo({
					url: '../user/attestation',
					animationType: 'pop-in',
					animationDuration: 200
				})
			},
			updatePassword() {
				uni.navigateTo({
					url: '../user/updatePassword',
					animationType: 'pop-in',
					animationDuration: 200
				})
			},
			outLogin() {
				outLogin().then(res=>{
					if(res.header.code == 200){
						console.log(JSON.stringify(res))
						uni.showToast({
							icon: 'success',
							title: '成功退出',
							duration: 2000
						});
						uni.removeStorageSync("token");
						uni.removeStorageSync("user");
						this.$forceUpdate();
						uni.switchTab({
							url: './index',
						});
					}
				})				
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f8f8f8;
	}

	.navbar-right {
		margin-right: 24rpx;
		display: flex;
	}

	.right-item {
		margin: 0 12rpx;
		position: relative;
		color: #000000;
		display: flex;
	}

	.nickName {
		color: #6a5018;
		font-size: 18px;
		font-weight: bold;
	}

	.regist-login {
		margin-left: 60upx;
		margin-top: 30upx;
	}

	.footer {
		margin-top: 800upx;
		background-color: #ff0000;
		color: #ffffff;
	}
</style>
